package com.silp.baitap1;

import java.util.Scanner;

public class Tinhtoan {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
	
		System.out.println("Nhap a");
		int a= sc.nextInt();
		System.out.println("Nhap b");
		int b= sc.nextInt();
		System.out.println("Chon phep tinh :");
		System.out.println("+ :");
		System.out.println("- :");
		System.out.println("x :");
		System.out.println("% :");
		String giatrichon = sc.next();
		
		switch (giatrichon) {
		case ("+"):
			add(a,b);
			break;
		case ("-"):
			sub(a, b);
			break;
		case ("x"):
			mul(a,b);
			break;
		case ("%"):
			div(a,b);
			break;
		}
	}

	private static int div(int a, int b) {
		int c = 0;
		if((a==0)||(b==0)||(div(a, b)==0)){
			System.out.println("Sai dieu kien");
		}
		else {
		c = a%b;
		System.out.println("Ket qua la "+c);
		}
		
		return c;
	}

	private static int mul(int a, int b) {
		int c = a*b;
		System.out.println("Ket qua la "+c);
		return c;
		
	}

	private static int sub(int a, int b) {
		
		int c=0;
		if((a<b)||(sub(a, b)==0)){
			System.out.println("Sai dieu kien");
			
		}
		else {
			c=a-b;
			System.out.println("Ket qua la "+c);
		}
		
		return c;
		
	}

	private static int add(int a, int b) {
		int c = a+b;
		System.out.println("Ket qua la "+c);
		return c;
		
	}

}
